package cn.village.service.impl;
import cn.village.dao.LoanContractMapper;
import cn.village.entity.LoanContract;
import cn.village.service.LoanContractService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class LoanContractServiceImpl implements LoanContractService {

    @Resource
    private LoanContractMapper loanContractMapper;

    public LoanContract getLoanContractById(String id)throws Exception{
        return loanContractMapper.getLoanContractById(id);
    }

    public List<LoanContract>	getLoanContractListByMap(Map<String,Object> param)throws Exception{
        return loanContractMapper.getLoanContractListByMap(param);
    }

    public Integer getLoanContractCountByMap(Map<String,Object> param)throws Exception{
        return loanContractMapper.getLoanContractCountByMap(param);
    }

    public Integer qdtxAddLoanContract(LoanContract loanContract)throws Exception{
            //loanContract.setCreatedTime(new Date());
            return loanContractMapper.insertLoanContract(loanContract);
    }

    public Integer qdtxModifyLoanContract(LoanContract loanContract)throws Exception{
        //loanContract.setUpdatedTime(new Date());
        return loanContractMapper.updateLoanContract(loanContract);
    }

    public Integer qdtxDeleteLoanContractById(String id)throws Exception{
        return loanContractMapper.deleteLoanContractById(id);
    }

    public Integer qdtxBatchDeleteLoanContract(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return loanContractMapper.batchDeleteLoanContract(param);
    }


}
